package com.android.resetfile.controller;

import com.android.resetfile.frame.IndexFrame;
import com.sun.deploy.uitoolkit.impl.fx.ui.FXAboutDialog;
import com.sun.deploy.uitoolkit.impl.fx.ui.FXMessageDialog;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.Button;
import javafx.scene.control.PasswordField;
import javafx.scene.control.TextField;
import javafx.scene.input.TouchEvent;
import javafx.scene.layout.Pane;

import javax.swing.*;
import java.net.URL;
import java.util.ResourceBundle;

public class Controller extends Pane implements Initializable {

    private IndexFrame application;
    @FXML
    Button login_btn;
    @FXML
    Button reset_btn;
    @FXML
    PasswordField password_txt;
    @FXML
    TextField account_txt;


    @Override
    public void initialize(URL url, ResourceBundle resourceBundle) {
        initEvent();
    }

    private void initEvent() {
        login_btn.setOnAction(new EventHandler<ActionEvent>() {
            @Override
            public void handle(ActionEvent actionEvent) {
                String account = account_txt.getText();
                String password = password_txt.getText();
                if ("admin".equals(account)&&"admin".equals(password))
                {

                    application.dispose();
                }else
                {
                    JOptionPane.showMessageDialog(application, "账号密码不正确");
                }

            }
        });
    }

    public void init(IndexFrame indexFrame) {
        this.application = indexFrame;
    }
}
